package com.ruoyi.web.controller.pay;

import com.jianqiao.delivery.pay.service.R2PService;
import com.jianqiao.delivery.pay.service.SripeVisaService;
import com.nimbusds.jose.JOSEException;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.spec.InvalidKeySpecException;

/**
 * author: cyx
 * create: 2024/11/23 10:00
 **/
@RestController
@RequestMapping("/visa")
public class VisaPayController {

    @Autowired
    private R2PService r2PService;

    @Autowired
    private SripeVisaService sripeVisaService;

    @PostMapping("/createR2P")
    public void createR2P() throws UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, KeyManagementException, InvalidKeySpecException, JOSEException {
        r2PService.initiateR2P();
    }

    @PostMapping("/createOrder")
    public AjaxResult createOrder() {
        String order = sripeVisaService.createOrder();
        return AjaxResult.success(order);
    }
}
